package Test1;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SeasonEntry extends JFrame implements ActionListener {
	
	private boolean DEBUG = false;
	JPanel panel1 = new JPanel();
	JPanel panel2 = new JPanel();
	JPanel panel3 = new JPanel();
	JLabel SeasonL = new JLabel("Season:");
	JTextField SeasonCodeT = new JTextField();
	JLabel SeasonCodeL = new JLabel("Season Code:");
	JTextField SeasonT = new JTextField();
	JButton searchb = new JButton("Search");
	JLabel newseasonl = new JLabel("Season Code:");
	JTextField newseasont = new JTextField();
	JButton AddB = new JButton("Add");
	JButton Close = new JButton("Close");	

public SeasonEntry(){
		super("Season Entry");
		setSize(600,650);
		setLocation(300,50);
		panel1.setLayout(null);

		
		/*			
		SeasonCodeL.setBounds(25,25,80,20);
		SeasonCodeT.setBounds(110,25,50,20);
		SeasonCodeT.setDocument(new JTextFieldLimit(6));
		
		SeasonL.setBounds(165,25,150,20);
		SeasonT.setBounds(220,25,85,20);
		SeasonT.setDocument(new JTextFieldLimit(11));
		searchb.setBounds(25, 50, 80, 20);
		
		
		 JPanel controls = new JPanel();
	     controls.add(layerList);
	     controls.add(onTop);
	     controls.setBorder(BorderFactory.createTitledBorder(
	                                 "Choose Duke's Layer and Position"));
	     return controls;
	*/	
		
		
		
		
		String [] columnNames = {"Season Code", "Season Discription"};
		
		Object [][] data = {{"SP2013", "SPRING 2013"},{"FA2013", "Fall 2013"}};
		
		 final JTable table = new JTable(data, columnNames);
	        table.setPreferredScrollableViewportSize(new Dimension(500, 70));
	        table.setBounds(25, 190, 900, 200);
	        table.setEnabled(true);
	        table.setFillsViewportHeight(true);

	        if (DEBUG) {
	            table.addMouseListener(new MouseAdapter() {
	                public void mouseClicked(MouseEvent e) {
	                    printDebugData(table);
	                }
	            });
	        }

	        //Create the scroll pane and add the table to it.
	        JScrollPane scrollPane = new JScrollPane(table);

	        //Add the scroll pane to this panel.
	        add(scrollPane);

		
		newseasonl.setBounds(50,350,80,20);		
		newseasont.setBounds(135,350,50,20);
		newseasont.setDocument(new JTextFieldLimit(6));
		
		AddB.setBounds(50,400,80,20);
		Close.setBounds(160,400,80,20);		
		Close.setForeground(Color.red);
		
		panel1.add(SeasonL);
		panel1.add(SeasonCodeT);
		panel1.add(SeasonCodeL);
		panel1.add(SeasonT);
		panel1.add(searchb);
		panel1.add(newseasonl);
		panel1.add(newseasont);
		panel1.add(AddB);
		panel1.add(Close);
		panel1.add(table);
		
		getContentPane().add(panel1);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
		actioncompany();

	}
	
private void printDebugData(JTable table) {
    int numRows = table.getRowCount();
    int numCols = table.getColumnCount();
    javax.swing.table.TableModel model = table.getModel();

    System.out.println("Value of data: ");
    for (int i=0; i < numRows; i++) {
        System.out.print("    row " + i + ":");
        for (int j=0; j < numCols; j++) {
            System.out.print("  " + model.getValueAt(i, j));
        }
        System.out.println();
    }
    System.out.println("--------------------------");
	}


	public void actioncompany(){
		AddB.addActionListener(new ActionListener() {
			
	
			public void actionPerformed(ActionEvent ae) {
				
				SeasonEntry seasonentry = new SeasonEntry();
				dispose();

			}
		});
		Close.addActionListener(new ActionListener(){
			
				public void actionPerformed(ActionEvent e) {
					dispose();
					
				}
		});
	}
	
	
	public static void main(String[] args) {

		SeasonEntry seasonentry = new SeasonEntry();
}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}
}
